** This do-file conducts the analysis demonstrating polarization in legislatures
** This re-produces Figures 4.2 and 4.3

* Open the dataset on campaign finance laws to sort for merging
use masterdataset, clear
sort statabbr year
save temp, replace

* Open the dataset on legislator ideal points (Shor/McCarty) and merge in laws dataset
use npat1996_2008, clear
sort statabbr year
merge statabbr year using temp

* Generate indicator of whether state is among 20 most professional legislatures
gen professional2=1 if statabbr=="CA" | statabbr=="NY" | statabbr=="PA" | statabbr=="MI" | statabbr=="IL" | statabbr=="MA" | statabbr=="WI" | statabbr=="OH" | statabbr=="FL" | statabbr=="NJ" | statabbr=="AK" | statabbr=="DE" | statabbr=="MN" | statabbr=="TX" | statabbr=="WA" | statabbr=="CT" | statabbr=="HI" | statabbr=="NC" | statabbr=="SC" | statabbr=="AZ" 

* This creates a second variable that treats high limits as unlimited as a robustness check
gen l_party_cand2=l_party_cand
replace l_party_cand2=0 if l_party_cand>=50000

* Generate a variable indicating if state has no limits on giving or receiving by parties
gen bothunlimited=1 if l_party_cand==0 & l_ind_party==0
replace bothunlimited=0 if l_party_cand==1 | l_ind_party==1

* Drop extreme outliers on ideal points
drop if np_score<-2 | np_score>2

* Label limits variable
label define limits 0 "Limits on Parties" 1 "No Limits on Parties"
label values bothunlimited limits

* All Legislatures - Comparing states with limits on either giving or receiving versus
* states without limits on giving or receiving. Creates Figure 4.2

twoway kdensity np_score if bothunlimited==1 & party=="D" , lc(black) || kdensity np_score if bothunlimited==0 & party=="D" , lc(black) lp(dash) || kdensity np_score if bothunlimited==1 & party=="R" , lc(black) lp(longdash) || kdensity np_score if bothunlimited==0 & party=="R" , lp(vshortdash) lc(black) scheme(s1color) title(" ") xtitle("Ideology") ytitle("Density") legend(lab(1 "Dems - Party Unlimited") lab(3 "Reps - Party Unlimited") lab(2 "Dems - Party Limited") lab(4 "Reps - Party Limited"))
graph export fig_4_2.eps, replace

* Reproduces Figure 4.3 ... For just professional legislatures
twoway kdensity np_score if  party=="D" & professional2==1, by(bothunlimited, col(1) legend(off) note(" ")) lc(black) xtitle("Ideology") ytitle(" ") ylabel(0 " ", nogrid notick) || kdensity np_score if party=="R" & professional2==1,  lc(black) lp(dash) 



